% Return the probability of combination a and b given the probability of
% digit 1 is p
function pab = prob(a, b, m, n, p)
pa = 1;
pb = 1;
for i = 0:m-1
    a = a * 2;
    if (a >= double(1))
        pa = pa * p;
        a = double(a - 1.0);
    else
        pa = pa * (1-p);
    end
    
end
for j = 0:n-1
    b = b * 2;
    if (b >= double(1))
        pb = pb * p;      
        b = double(b - 1.0);
    else
        pb = pb * (1-p);
    end
    
end
pab = pa * pb;
end